package com.auto.oa.menu.service.impl;

import java.util.List;
import java.util.Map;

import com.auto.oa.menu.dao.OaMenuDAOFactory;
import com.auto.oa.menu.domain.OaMenuRole;
import com.auto.oa.menu.domain.OaMenuRoleExtend;
import com.auto.oa.menu.domain.OaMenuRoleUserMap;
import com.auto.oa.menu.service.IOaMenuRoleService;
import com.system.common.Page;
import com.system.util.BeanUtil;

public class OaMenuRoleServiceImpl implements IOaMenuRoleService {

	public List<OaMenuRole> queryPageListOaMenuRole(OaMenuRole bean, Page page) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(bean);
			List<OaMenuRole> resultList = OaMenuDAOFactory.oaMenuRoleDAO.queryList(param, page);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public List<OaMenuRole> queryTreeOaMenuRole(OaMenuRole bean) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(bean);
			List<OaMenuRole> resultList = OaMenuDAOFactory.oaMenuRoleDAO.queryList(param);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean saveOrUpdateOaMenuRole(OaMenuRole bean) throws Exception {
		try {
			boolean bool = false;
			if(BeanUtil.isObjectNotNull(bean)){
				if(BeanUtil.isBlank(bean.getAproGuid())){
					OaMenuDAOFactory.oaMenuRoleDAO.insertOaMenuRole(bean);
					bool = true;
				}else{
					OaMenuDAOFactory.oaMenuRoleDAO.updateOaMenuRole(bean);
					bool = true;
				}
			}
			
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean deleteOaMenuRole(String guid) throws Exception {
		try {
			boolean bool = false;
			if(!BeanUtil.isBlank(guid)){
				OaMenuDAOFactory.oaMenuRoleDAO.deleteOaMenuRole(guid);
				bool = true;
			}
			
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public OaMenuRole getOaMenuRole(String guid) throws Exception {
		try {
			OaMenuRole result = null;
			if(!BeanUtil.isBlank(guid)){
				result = OaMenuDAOFactory.oaMenuRoleDAO.loadOaMenuRole(guid);
			}
			
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public List<OaMenuRoleExtend> queryPageListOaMenuRoleExtend(OaMenuRoleExtend bean, Page page) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(bean);
			List<OaMenuRoleExtend> resultList = OaMenuDAOFactory.oaMenuRoleDAO.queryListOaMenuRoleExtend(param, page);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean saveOrUpdateOaMenuRoleUserMap(OaMenuRoleUserMap bean) throws Exception {
		try {
			boolean bool = false;
			if(BeanUtil.isObjectNotNull(bean)){
				if(BeanUtil.isBlank(bean.getAprumGuid())){
					OaMenuDAOFactory.oaMenuRoleUserMapDAO.insertOaMenuRoleUserMap(bean);
					bool = true;
				}else{
					OaMenuDAOFactory.oaMenuRoleUserMapDAO.updateOaMenuRoleUserMap(bean);
					bool = true;
				}
			}
			
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean deleteOaMenuRoleUserMap(String guid) throws Exception {
		try {
			boolean bool = false;
			if(!BeanUtil.isBlank(guid)){
				OaMenuDAOFactory.oaMenuRoleUserMapDAO.deleteOaMenuRoleUserMap(guid);
				bool = true;
			}
			
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public List<OaMenuRoleUserMap> queryListOaMenuRoleUserMap(OaMenuRoleUserMap bean) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(bean);
			List<OaMenuRoleUserMap> resultList = OaMenuDAOFactory.oaMenuRoleUserMapDAO.queryList(param);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

}
